import time
import pymysql
from selenium import webdriver
from selenium.webdriver.common.by import By
from unittest import TestCase


class TestManage(TestCase):

    def testManage1(self):
        connect = pymysql.connect(host='localhost', user='root', password='123456', database='finance')
        cursor = connect.cursor()
        sql = ' select id from user where username="lisi"'
        cursor.execute(sql)
        x = cursor.fetchall()
        id = x[0][0]
        sql = f'select balance from bankcard where defaultl=1 and userId={id}'
        cursor.execute(sql)
        y = cursor.fetchall()
        money1 = y[0][0]
        self.assertGreaterEqual(money1, 100)
        driver = webdriver.Chrome()

        driver.maximize_window()

        driver.get("http://localhost:90")

        time.sleep(2)

        ele1 = driver.find_element(By.XPATH, "//input[@id='username']")
        ele1.send_keys("lisi")

        ele2 = driver.find_element(By.XPATH, "//input[@id='password']")
        ele2.send_keys("123456")

        ele3 = driver.find_element(By.XPATH, "//button[@id='login_btn']")
        ele3.click()

        time.sleep(3)

        ele4 = driver.find_element(By.XPATH, '//*[@id="leftbaraside"]/div[2]/nav/ul/li[2]/a')
        ele4.click()

        time.sleep(1)

        ele5 = driver.find_element(By.XPATH, '//*[@id="leftbaraside"]/div[2]/nav/ul/li[2]/ul/li[1]/a')
        ele5.click()

        time.sleep(1)

        ele6 = driver.find_element(By.XPATH,
                                   "/html/body/div/div/main/div/div/div/div/div[2]/div/table/tbody/tr[1]/td[6]/button")
        ele6.click()

        time.sleep(1)

        ele7 = driver.find_elements(By.XPATH, "//*[@id='password']")[1]
        ele7.send_keys("666666")

        time.sleep(1)

        ele8 = driver.find_element(By.XPATH, "//*[@id='layui-layer1']/div[3]/a[1]")
        ele8.click()

        time.sleep(1)

        result = driver.find_element(By.XPATH,
                                     "/html/body/div[3]/div[2]/div/div/div/div/div/div/div/div[3]/div/div").text

        if result != "买入成功!":
            driver.save_screenshot("lisi投资1.jpg")

        self.assertEqual(result, "买入成功!")
        connect.commit()
        sql = f'select balance from bankcard where defaultl=1 and userId={id}'
        cursor.execute(sql)
        y = cursor.fetchall()
        money2 = y[0][0]
        self.assertEqual(money1 - 100, money2)

        driver.quit()

    def testManage2(self):
        connect = pymysql.connect(host='localhost', user='root', password='123456', database='finance')
        cursor = connect.cursor()
        sql = ' select id from user where username="lisi"'
        cursor.execute(sql)
        x = cursor.fetchall()
        id = x[0][0]
        sql = f'select balance from bankcard where defaultl=1 and userId={id}'
        cursor.execute(sql)
        y = cursor.fetchall()
        money1 = y[0][0]
        self.assertGreaterEqual(money1, 100)
        driver = webdriver.Chrome()

        driver.maximize_window()

        driver.get("http://localhost:90")

        time.sleep(2)

        ele1 = driver.find_element(By.XPATH, "//input[@id='username']")
        ele1.send_keys("lisi")

        ele2 = driver.find_element(By.XPATH, "//input[@id='password']")
        ele2.send_keys("123456")

        ele3 = driver.find_element(By.XPATH, "//button[@id='login_btn']")
        ele3.click()

        time.sleep(3)

        ele4 = driver.find_element(By.XPATH, '//*[@id="leftbaraside"]/div[2]/nav/ul/li[2]/a')
        ele4.click()

        time.sleep(1)

        ele5 = driver.find_element(By.XPATH, '//*[@id="leftbaraside"]/div[2]/nav/ul/li[2]/ul/li[1]/a')
        ele5.click()

        time.sleep(1)

        ele6 = driver.find_element(By.XPATH,
                                   "/html/body/div/div/main/div/div/div/div/div[2]/div/table/tbody/tr[1]/td[6]/button")
        ele6.click()

        time.sleep(1)

        ele7 = driver.find_elements(By.XPATH, "//*[@id='password']")[1]
        ele7.send_keys("666667")

        time.sleep(1)

        ele8 = driver.find_element(By.XPATH, "//*[@id='layui-layer1']/div[3]/a[1]")
        ele8.click()

        time.sleep(1)

        result = driver.find_element(By.XPATH,
                                     "/html/body/div[3]/div[2]/div/div/div/div/div/div/div/div[3]/div/div").text

        if result != "买入失败!":
            driver.save_screenshot("lisi投资2.jpg")

        self.assertEqual(result, "买入失败!")
        connect.commit()
        sql = f'select balance from bankcard where defaultl=1 and userId={id}'
        cursor.execute(sql)
        y = cursor.fetchall()
        money2 = y[0][0]
        self.assertEqual(money1, money2)
        driver.quit()

    def testManage3(self):
        connect = pymysql.connect(host='localhost', user='root', password='123456', database='finance')
        cursor = connect.cursor()
        sql = ' select id from user where username="lisi4"'
        cursor.execute(sql)
        x = cursor.fetchall()
        id = x[0][0]
        sql = f'select balance from bankcard where defaultl=1 and userId={id}'
        cursor.execute(sql)
        y = cursor.fetchall()
        money1 = y[0][0]
        self.assertGreaterEqual(100, money1)
        driver = webdriver.Chrome()

        driver.maximize_window()

        driver.get("http://localhost:90")

        time.sleep(2)

        ele1 = driver.find_element(By.XPATH, "//input[@id='username']")
        ele1.send_keys("lisi4")

        ele2 = driver.find_element(By.XPATH, "//input[@id='password']")
        ele2.send_keys("123456")

        ele3 = driver.find_element(By.XPATH, "//button[@id='login_btn']")
        ele3.click()

        time.sleep(3)

        ele4 = driver.find_element(By.XPATH, '//*[@id="leftbaraside"]/div[2]/nav/ul/li[2]/a')
        ele4.click()

        time.sleep(1)

        ele5 = driver.find_element(By.XPATH, '//*[@id="leftbaraside"]/div[2]/nav/ul/li[2]/ul/li[1]/a')
        ele5.click()

        time.sleep(1)

        ele6 = driver.find_element(By.XPATH,
                                   "/html/body/div/div/main/div/div/div/div/div[2]/div/table/tbody/tr[1]/td[6]/button")
        ele6.click()

        time.sleep(1)

        ele7 = driver.find_elements(By.XPATH, "//*[@id='password']")[1]
        ele7.send_keys("666666")

        time.sleep(1)

        ele8 = driver.find_element(By.XPATH, "//*[@id='layui-layer1']/div[3]/a[1]")
        ele8.click()

        time.sleep(1)

        result = driver.find_element(By.XPATH,
                                     "/html/body/div[3]/div[2]/div/div/div/div/div/div/div/div[3]/div/div").text

        if result != "买入失败!，银行卡余额不足":
            driver.save_screenshot("lisi4投资3.jpg")

        self.assertEqual(result, "买入失败!，银行卡余额不足")
        connect.commit()
        sql = f'select balance from bankcard where defaultl=1 and userId={id}'
        cursor.execute(sql)
        y = cursor.fetchall()
        money2 = y[0][0]
        self.assertEqual(money1, money2)
        driver.quit()

    def testManage4(self):

        driver = webdriver.Chrome()

        driver.maximize_window()

        driver.get("http://localhost:90")

        time.sleep(2)

        ele1 = driver.find_element(By.XPATH, "//input[@id='username']")
        ele1.send_keys("lisi5")

        ele2 = driver.find_element(By.XPATH, "//input[@id='password']")
        ele2.send_keys("123456")

        ele3 = driver.find_element(By.XPATH, "//button[@id='login_btn']")
        ele3.click()

        time.sleep(3)

        ele4 = driver.find_element(By.XPATH, '//*[@id="leftbaraside"]/div[2]/nav/ul/li[2]/a')
        ele4.click()

        time.sleep(1)

        ele5 = driver.find_element(By.XPATH, '//*[@id="leftbaraside"]/div[2]/nav/ul/li[2]/ul/li[1]/a')
        ele5.click()

        time.sleep(1)

        ele6 = driver.find_element(By.XPATH,
                                   "/html/body/div/div/main/div/div/div/div/div[2]/div/table/tbody/tr[1]/td[6]/button")
        ele6.click()

        time.sleep(1)

        ele7 = driver.find_elements(By.XPATH, "//*[@id='password']")[1]
        ele7.send_keys("666666")

        time.sleep(1)

        ele8 = driver.find_element(By.XPATH, "//*[@id='layui-layer1']/div[3]/a[1]")
        ele8.click()

        time.sleep(1)

        result = driver.find_element(By.XPATH,
                                     "/html/body/div[3]/div[2]/div/div/div/div/div/div/div/div[3]/div/div").text

        if result != "买入失败!，请绑定银行卡":
            driver.save_screenshot("lisi5投资4.jpg")

        self.assertEqual(result, "买入失败!，请绑定银行卡")

        driver.quit()

    def testManage5(self):
        connect = pymysql.connect(host='localhost', user='root', password='123456', database='finance')
        cursor = connect.cursor()
        sql = ' select id from user where username="lisi"'
        cursor.execute(sql)
        x = cursor.fetchall()
        id = x[0][0]
        sql = f'select balance from bankcard where defaultl=1 and userId={id}'
        cursor.execute(sql)
        y = cursor.fetchall()
        money1 = y[0][0]
        self.assertGreaterEqual(money1, 100)
        driver = webdriver.Chrome()

        driver.maximize_window()

        driver.get("http://localhost:90")

        time.sleep(2)

        ele1 = driver.find_element(By.XPATH, "//input[@id='username']")
        ele1.send_keys("lisi")

        ele2 = driver.find_element(By.XPATH, "//input[@id='password']")
        ele2.send_keys("123456")

        ele3 = driver.find_element(By.XPATH, "//button[@id='login_btn']")
        ele3.click()

        time.sleep(3)

        ele4 = driver.find_element(By.XPATH, '//*[@id="leftbaraside"]/div[2]/nav/ul/li[2]/a')
        ele4.click()

        time.sleep(1)

        ele5 = driver.find_element(By.XPATH, '/html/body/div[1]/div/aside/div[2]/nav/ul/li[2]/ul/li[2]/a')
        ele5.click()

        time.sleep(1)

        ele6 = driver.find_element(By.XPATH,
                                   "/html/body/div/div/main/div/div/div/div/div[2]/div/table/tbody/tr[1]/td[8]/button")
        ele6.click()

        time.sleep(1)

        ele7 = driver.find_elements(By.XPATH, "//*[@id='password']")[1]
        ele7.send_keys("666666")

        time.sleep(1)

        ele8 = driver.find_element(By.XPATH, "//*[@id='layui-layer1']/div[3]/a[1]")
        ele8.click()

        time.sleep(1)

        result = driver.find_element(By.XPATH,
                                     "/html/body/div[3]/div[2]/div/div/div/div/div/div/div/div[3]/div/div").text

        if result != "买入成功!":
            driver.save_screenshot("lisi投资5.jpg")

        self.assertEqual(result, "买入成功!")
        connect.commit()
        sql = f'select balance from bankcard where defaultl=1 and userId={id}'
        cursor.execute(sql)
        y = cursor.fetchall()
        money2 = y[0][0]
        self.assertEqual(money1 - 5000, money2)

        driver.quit()

    def testManage6(self):
        connect = pymysql.connect(host='localhost', user='root', password='123456', database='finance')
        cursor = connect.cursor()
        sql = ' select id from user where username="lisi"'
        cursor.execute(sql)
        x = cursor.fetchall()
        id = x[0][0]
        sql = f'select balance from bankcard where defaultl=1 and userId={id}'
        cursor.execute(sql)
        y = cursor.fetchall()
        money1 = y[0][0]
        self.assertGreaterEqual(money1, 100)
        driver = webdriver.Chrome()

        driver.maximize_window()

        driver.get("http://localhost:90")

        time.sleep(2)

        ele1 = driver.find_element(By.XPATH, "//input[@id='username']")
        ele1.send_keys("lisi")

        ele2 = driver.find_element(By.XPATH, "//input[@id='password']")
        ele2.send_keys("123456")

        ele3 = driver.find_element(By.XPATH, "//button[@id='login_btn']")
        ele3.click()

        time.sleep(3)

        ele4 = driver.find_element(By.XPATH, '//*[@id="leftbaraside"]/div[2]/nav/ul/li[2]/a')
        ele4.click()

        time.sleep(1)

        ele5 = driver.find_element(By.XPATH, '/html/body/div[1]/div/aside/div[2]/nav/ul/li[2]/ul/li[2]/a')
        ele5.click()

        time.sleep(1)

        ele6 = driver.find_element(By.XPATH,
                                   "/html/body/div/div/main/div/div/div/div/div[2]/div/table/tbody/tr[1]/td[8]/button")
        ele6.click()

        time.sleep(1)

        ele7 = driver.find_elements(By.XPATH, "//*[@id='password']")[1]
        ele7.send_keys("666667")

        time.sleep(1)

        ele8 = driver.find_element(By.XPATH, "//*[@id='layui-layer1']/div[3]/a[1]")
        ele8.click()

        time.sleep(1)

        result = driver.find_element(By.XPATH,
                                     "/html/body/div[3]/div[2]/div/div/div/div/div/div/div/div[3]/div/div").text

        if result != "买入失败!":
            driver.save_screenshot("lisi投资6.jpg")

        self.assertEqual(result, "买入失败!")
        connect.commit()
        sql = f'select balance from bankcard where defaultl=1 and userId={id}'
        cursor.execute(sql)
        y = cursor.fetchall()
        money2 = y[0][0]
        self.assertEqual(money1, money2)
        driver.quit()

    def testManage7(self):
        connect = pymysql.connect(host='localhost', user='root', password='123456', database='finance')
        cursor = connect.cursor()
        sql = ' select id from user where username="lisi4"'
        cursor.execute(sql)
        x = cursor.fetchall()
        id = x[0][0]
        sql = f'select balance from bankcard where defaultl=1 and userId={id}'
        cursor.execute(sql)
        y = cursor.fetchall()
        money1 = y[0][0]
        self.assertGreaterEqual(100, money1)
        driver = webdriver.Chrome()

        driver.maximize_window()

        driver.get("http://localhost:90")

        time.sleep(2)

        ele1 = driver.find_element(By.XPATH, "//input[@id='username']")
        ele1.send_keys("lisi4")

        ele2 = driver.find_element(By.XPATH, "//input[@id='password']")
        ele2.send_keys("123456")

        ele3 = driver.find_element(By.XPATH, "//button[@id='login_btn']")
        ele3.click()

        time.sleep(3)

        ele4 = driver.find_element(By.XPATH, '//*[@id="leftbaraside"]/div[2]/nav/ul/li[2]/a')
        ele4.click()

        time.sleep(1)

        ele5 = driver.find_element(By.XPATH, '/html/body/div[1]/div/aside/div[2]/nav/ul/li[2]/ul/li[2]/a')
        ele5.click()

        time.sleep(1)

        ele6 = driver.find_element(By.XPATH,
                                   "/html/body/div/div/main/div/div/div/div/div[2]/div/table/tbody/tr[1]/td[8]/button")
        ele6.click()

        time.sleep(1)

        ele7 = driver.find_elements(By.XPATH, "//*[@id='password']")[1]
        ele7.send_keys("666666")

        time.sleep(1)

        ele8 = driver.find_element(By.XPATH, "//*[@id='layui-layer1']/div[3]/a[1]")
        ele8.click()

        time.sleep(1)

        result = driver.find_element(By.XPATH,
                                     "/html/body/div[3]/div[2]/div/div/div/div/div/div/div/div[3]/div/div").text

        if result != "买入失败!，银行卡余额不足":
            driver.save_screenshot("lisi4投资7.jpg")

        self.assertEqual(result, "买入失败!，银行卡余额不足")
        connect.commit()
        sql = f'select balance from bankcard where defaultl=1 and userId={id}'
        cursor.execute(sql)
        y = cursor.fetchall()
        money2 = y[0][0]
        self.assertEqual(money1, money2)
        driver.quit()

    def testManage8(self):

        driver = webdriver.Chrome()

        driver.maximize_window()

        driver.get("http://localhost:90")

        time.sleep(2)

        ele1 = driver.find_element(By.XPATH, "//input[@id='username']")
        ele1.send_keys("lisi5")

        ele2 = driver.find_element(By.XPATH, "//input[@id='password']")
        ele2.send_keys("123456")

        ele3 = driver.find_element(By.XPATH, "//button[@id='login_btn']")
        ele3.click()

        time.sleep(3)

        ele4 = driver.find_element(By.XPATH, '//*[@id="leftbaraside"]/div[2]/nav/ul/li[2]/a')
        ele4.click()

        time.sleep(1)

        ele5 = driver.find_element(By.XPATH, '/html/body/div[1]/div/aside/div[2]/nav/ul/li[2]/ul/li[2]/a')
        ele5.click()

        time.sleep(1)

        ele6 = driver.find_element(By.XPATH,
                                   "/html/body/div/div/main/div/div/div/div/div[2]/div/table/tbody/tr[1]/td[8]/button")
        ele6.click()

        time.sleep(1)

        ele7 = driver.find_elements(By.XPATH, "//*[@id='password']")[1]
        ele7.send_keys("666666")

        time.sleep(1)

        ele8 = driver.find_element(By.XPATH, "//*[@id='layui-layer1']/div[3]/a[1]")
        ele8.click()

        time.sleep(1)

        result = driver.find_element(By.XPATH,
                                     "/html/body/div[3]/div[2]/div/div/div/div/div/div/div/div[3]/div/div").text

        if result != "买入失败!，请绑定银行卡":
            driver.save_screenshot("lisi5投资8.jpg")

        self.assertEqual(result, "买入失败!，请绑定银行卡")

        driver.quit()

    def testManage9(self):
        connect = pymysql.connect(host='localhost', user='root', password='123456', database='finance')
        cursor = connect.cursor()
        sql = ' select id from user where username="lisi"'
        cursor.execute(sql)
        x = cursor.fetchall()
        id = x[0][0]
        sql = f'select balance from bankcard where defaultl=1 and userId={id}'
        cursor.execute(sql)
        y = cursor.fetchall()
        money1 = y[0][0]
        self.assertGreaterEqual(money1, 100)
        driver = webdriver.Chrome()

        driver.maximize_window()

        driver.get("http://localhost:90")

        time.sleep(2)

        ele1 = driver.find_element(By.XPATH, "//input[@id='username']")
        ele1.send_keys("lisi")

        ele2 = driver.find_element(By.XPATH, "//input[@id='password']")
        ele2.send_keys("123456")

        ele3 = driver.find_element(By.XPATH, "//button[@id='login_btn']")
        ele3.click()

        time.sleep(3)

        ele4 = driver.find_element(By.XPATH, '//*[@id="leftbaraside"]/div[2]/nav/ul/li[2]/a')
        ele4.click()

        time.sleep(1)

        ele5 = driver.find_element(By.XPATH, '/html/body/div/div/aside/div[2]/nav/ul/li[2]/ul/li[3]/a')
        ele5.click()

        time.sleep(1)

        ele6 = driver.find_element(By.XPATH,
                                   "/html/body/div/div/main/div/div/div/div/div[2]/div/table/tbody/tr[1]/td[9]/button")
        ele6.click()

        time.sleep(1)

        ele7 = driver.find_elements(By.XPATH, "//*[@id='password']")[1]
        ele7.send_keys("666666")

        time.sleep(1)

        ele8 = driver.find_element(By.XPATH, "//*[@id='layui-layer1']/div[3]/a[1]")
        ele8.click()

        time.sleep(1)

        result = driver.find_element(By.XPATH,
                                     "/html/body/div[3]/div[2]/div/div/div/div/div/div/div/div[3]/div/div").text

        if result != "买入成功!":
            driver.save_screenshot("lisi投资9.jpg")

        self.assertEqual(result, "买入成功!")
        connect.commit()
        sql = f'select balance from bankcard where defaultl=1 and userId={id}'
        cursor.execute(sql)
        y = cursor.fetchall()
        money2 = y[0][0]
        self.assertEqual(money1 - 3000, money2)

        driver.quit()

    def testManage10(self):
        connect = pymysql.connect(host='localhost', user='root', password='123456', database='finance')
        cursor = connect.cursor()
        sql = ' select id from user where username="lisi"'
        cursor.execute(sql)
        x = cursor.fetchall()
        id = x[0][0]
        sql = f'select balance from bankcard where defaultl=1 and userId={id}'
        cursor.execute(sql)
        y = cursor.fetchall()
        money1 = y[0][0]
        self.assertGreaterEqual(money1, 100)
        driver = webdriver.Chrome()

        driver.maximize_window()

        driver.get("http://localhost:90")

        time.sleep(2)

        ele1 = driver.find_element(By.XPATH, "//input[@id='username']")
        ele1.send_keys("lisi")

        ele2 = driver.find_element(By.XPATH, "//input[@id='password']")
        ele2.send_keys("123456")

        ele3 = driver.find_element(By.XPATH, "//button[@id='login_btn']")
        ele3.click()

        time.sleep(3)

        ele4 = driver.find_element(By.XPATH, '//*[@id="leftbaraside"]/div[2]/nav/ul/li[2]/a')
        ele4.click()

        time.sleep(1)

        ele5 = driver.find_element(By.XPATH, '/html/body/div/div/aside/div[2]/nav/ul/li[2]/ul/li[3]/a')
        ele5.click()

        time.sleep(1)

        ele6 = driver.find_element(By.XPATH,
                                   "/html/body/div/div/main/div/div/div/div/div[2]/div/table/tbody/tr[1]/td[9]/button")
        ele6.click()

        time.sleep(1)

        ele7 = driver.find_elements(By.XPATH, "//*[@id='password']")[1]
        ele7.send_keys("666667")

        time.sleep(1)

        ele8 = driver.find_element(By.XPATH, "//*[@id='layui-layer1']/div[3]/a[1]")
        ele8.click()

        time.sleep(1)

        result = driver.find_element(By.XPATH,
                                     "/html/body/div[3]/div[2]/div/div/div/div/div/div/div/div[3]/div/div").text

        if result != "买入失败!":
            driver.save_screenshot("lisi投资10.jpg")

        self.assertEqual(result, "买入失败!")
        connect.commit()
        sql = f'select balance from bankcard where defaultl=1 and userId={id}'
        cursor.execute(sql)
        y = cursor.fetchall()
        money2 = y[0][0]
        self.assertEqual(money1, money2)
        driver.quit()

    def testManage11(self):
        connect = pymysql.connect(host='localhost', user='root', password='123456', database='finance')
        cursor = connect.cursor()
        sql = ' select id from user where username="lisi4"'
        cursor.execute(sql)
        x = cursor.fetchall()
        id = x[0][0]
        sql = f'select balance from bankcard where defaultl=1 and userId={id}'
        cursor.execute(sql)
        y = cursor.fetchall()
        money1 = y[0][0]
        self.assertGreaterEqual(100, money1)
        driver = webdriver.Chrome()

        driver.maximize_window()

        driver.get("http://localhost:90")

        time.sleep(2)

        ele1 = driver.find_element(By.XPATH, "//input[@id='username']")
        ele1.send_keys("lisi4")

        ele2 = driver.find_element(By.XPATH, "//input[@id='password']")
        ele2.send_keys("123456")

        ele3 = driver.find_element(By.XPATH, "//button[@id='login_btn']")
        ele3.click()

        time.sleep(3)

        ele4 = driver.find_element(By.XPATH, '//*[@id="leftbaraside"]/div[2]/nav/ul/li[2]/a')
        ele4.click()

        time.sleep(1)

        ele5 = driver.find_element(By.XPATH, '/html/body/div/div/aside/div[2]/nav/ul/li[2]/ul/li[3]/a')
        ele5.click()

        time.sleep(1)

        ele6 = driver.find_element(By.XPATH,
                                   "/html/body/div/div/main/div/div/div/div/div[2]/div/table/tbody/tr[1]/td[9]/button")
        ele6.click()

        time.sleep(1)

        ele7 = driver.find_elements(By.XPATH, "//*[@id='password']")[1]
        ele7.send_keys("666666")

        time.sleep(1)

        ele8 = driver.find_element(By.XPATH, "//*[@id='layui-layer1']/div[3]/a[1]")
        ele8.click()

        time.sleep(1)

        result = driver.find_element(By.XPATH,
                                     "/html/body/div[3]/div[2]/div/div/div/div/div/div/div/div[3]/div/div").text

        if result != "买入失败!，银行卡余额不足":
            driver.save_screenshot("lisi4投资11.jpg")

        self.assertEqual(result, "买入失败!，银行卡余额不足")
        connect.commit()
        sql = f'select balance from bankcard where defaultl=1 and userId={id}'
        cursor.execute(sql)
        y = cursor.fetchall()
        money2 = y[0][0]
        self.assertEqual(money1, money2)
        driver.quit()

    def testManage12(self):

        driver = webdriver.Chrome()

        driver.maximize_window()

        driver.get("http://localhost:90")

        time.sleep(2)

        ele1 = driver.find_element(By.XPATH, "//input[@id='username']")
        ele1.send_keys("lisi5")

        ele2 = driver.find_element(By.XPATH, "//input[@id='password']")
        ele2.send_keys("123456")

        ele3 = driver.find_element(By.XPATH, "//button[@id='login_btn']")
        ele3.click()

        time.sleep(3)

        ele4 = driver.find_element(By.XPATH, '//*[@id="leftbaraside"]/div[2]/nav/ul/li[2]/a')
        ele4.click()

        time.sleep(1)

        ele5 = driver.find_element(By.XPATH, '/html/body/div/div/aside/div[2]/nav/ul/li[2]/ul/li[3]/a')
        ele5.click()

        time.sleep(1)

        ele6 = driver.find_element(By.XPATH,
                                   "/html/body/div/div/main/div/div/div/div/div[2]/div/table/tbody/tr[1]/td[9]/button")
        ele6.click()

        time.sleep(1)

        ele7 = driver.find_elements(By.XPATH, "//*[@id='password']")[1]
        ele7.send_keys("666666")

        time.sleep(1)

        ele8 = driver.find_element(By.XPATH, "//*[@id='layui-layer1']/div[3]/a[1]")
        ele8.click()

        time.sleep(1)

        result = driver.find_element(By.XPATH,
                                     "/html/body/div[3]/div[2]/div/div/div/div/div/div/div/div[3]/div/div").text

        if result != "买入失败!，请绑定银行卡":
            driver.save_screenshot("lisi5投资12.jpg")

        self.assertEqual(result, "买入失败!，请绑定银行卡")

        driver.quit()

    def testManage13(self):

        driver = webdriver.Chrome()

        driver.maximize_window()

        driver.get("http://localhost:90")

        time.sleep(2)

        ele1 = driver.find_element(By.XPATH, "//input[@id='username']")
        ele1.send_keys("lisi6")

        ele2 = driver.find_element(By.XPATH, "//input[@id='password']")
        ele2.send_keys("123456")

        ele3 = driver.find_element(By.XPATH, "//button[@id='login_btn']")
        ele3.click()

        time.sleep(3)

        ele4 = driver.find_element(By.XPATH, '//*[@id="leftbaraside"]/div[2]/nav/ul/li[2]/a')
        ele4.click()

        time.sleep(1)

        ele5 = driver.find_element(By.XPATH, '/html/body/div/div/aside/div[2]/nav/ul/li[2]/ul/li[3]/a')
        ele5.click()

        time.sleep(1)

        ele6 = driver.find_element(By.XPATH,
                                   "/html/body/div/div/main/div/div/div/div/div[2]/div/table/tbody/tr[1]/td[9]/button")
        ele6.click()

        time.sleep(1)

        ele7 = driver.find_elements(By.XPATH, "//*[@id='password']")[1]
        ele7.send_keys("666666")

        time.sleep(1)

        ele8 = driver.find_element(By.XPATH, "//*[@id='layui-layer1']/div[3]/a[1]")
        ele8.click()

        time.sleep(1)

        result = driver.find_element(By.XPATH,
                                     "/html/body/div[3]/div[2]/div/div/div/div/div/div/div/div[3]/div/div").text

        if result != "买入失败!,请前往个人信息设置支付密码":
            driver.save_screenshot("lisi6投资13.jpg")

        self.assertEqual(result, "买入失败!,请前往个人信息设置支付密码")

        driver.quit()

    def testManage14(self):
        connect = pymysql.connect(host='localhost', user='root', password='123456', database='finance')
        cursor = connect.cursor()
        sql = ' select id from user where username="lisi7"'
        cursor.execute(sql)
        x = cursor.fetchall()
        id = x[0][0]
        sql = f'select balance from bankcard where defaultl=1 and userId={id}'
        cursor.execute(sql)
        y = cursor.fetchall()
        money1 = y[0][0]

        driver = webdriver.Chrome()

        driver.maximize_window()

        driver.get("http://localhost:90")

        time.sleep(2)

        ele1 = driver.find_element(By.XPATH, "//input[@id='username']")
        ele1.send_keys("lisi7")

        ele2 = driver.find_element(By.XPATH, "//input[@id='password']")
        ele2.send_keys("123456")

        ele3 = driver.find_element(By.XPATH, "//button[@id='login_btn']")
        ele3.click()

        time.sleep(3)

        ele4 = driver.find_element(By.XPATH, '//*[@id="leftbaraside"]/div[2]/nav/ul/li[2]/a')
        ele4.click()

        time.sleep(1)

        ele5 = driver.find_element(By.XPATH, '/html/body/div/div/aside/div[2]/nav/ul/li[2]/ul/li[3]/a')
        ele5.click()

        time.sleep(1)

        ele6 = driver.find_element(By.XPATH,
                                   "/html/body/div/div/main/div/div/div/div/div[2]/div/table/tbody/tr[1]/td[9]/button")
        ele6.click()

        time.sleep(1)

        ele7 = driver.find_elements(By.XPATH, "//*[@id='password']")[1]
        ele7.send_keys("666666")

        time.sleep(1)

        ele8 = driver.find_element(By.XPATH, "//*[@id='layui-layer1']/div[3]/a[1]")
        ele8.click()

        time.sleep(1)

        result = driver.find_element(By.XPATH,
                                     "/html/body/div[3]/div[2]/div/div/div/div/div/div/div/div[3]/div/div").text

        if result != "买入成功!":
            driver.save_screenshot("lisi7投资14.jpg")

        self.assertEqual(result, "买入成功!")
        connect.commit()
        sql = f'select balance from bankcard where defaultl=1 and userId={id}'
        cursor.execute(sql)
        y = cursor.fetchall()
        money2 = y[0][0]
        self.assertEqual(money1 - 3000, money2)

        driver.quit()

    def testManage15(self):
        connect = pymysql.connect(host='localhost', user='root', password='123456', database='finance')
        cursor = connect.cursor()
        sql = ' select id from user where username="lisi7"'
        cursor.execute(sql)
        x = cursor.fetchall()
        id = x[0][0]
        sql = f'select balance from bankcard where defaultl=1 and userId={id}'
        cursor.execute(sql)
        y = cursor.fetchall()
        money1 = y[0][0]

        driver = webdriver.Chrome()

        driver.maximize_window()

        driver.get("http://localhost:90")

        time.sleep(2)

        ele1 = driver.find_element(By.XPATH, "//input[@id='username']")
        ele1.send_keys("lisi7")

        ele2 = driver.find_element(By.XPATH, "//input[@id='password']")
        ele2.send_keys("123456")

        ele3 = driver.find_element(By.XPATH, "//button[@id='login_btn']")
        ele3.click()

        time.sleep(3)

        ele4 = driver.find_element(By.XPATH, '//*[@id="leftbaraside"]/div[2]/nav/ul/li[2]/a')
        ele4.click()

        time.sleep(1)

        ele5 = driver.find_element(By.XPATH, '/html/body/div/div/aside/div[2]/nav/ul/li[2]/ul/li[3]/a')
        ele5.click()

        time.sleep(1)

        ele6 = driver.find_element(By.XPATH,
                                   "/html/body/div/div/main/div/div/div/div/div[2]/div/table/tbody/tr[1]/td[9]/button")
        ele6.click()

        time.sleep(1)

        ele7 = driver.find_elements(By.XPATH, "//*[@id='password']")[1]
        ele7.send_keys("666666")

        time.sleep(1)

        ele8 = driver.find_element(By.XPATH, "//*[@id='layui-layer1']/div[3]/a[1]")
        ele8.click()

        time.sleep(1)

        result = driver.find_element(By.XPATH,
                                     "/html/body/div[3]/div[2]/div/div/div/div/div/div/div/div[3]/div/div").text

        if result != "买入成功!":
            driver.save_screenshot("lisi7投资15.jpg")

        self.assertEqual(result, "买入成功!")
        connect.commit()
        sql = f'select balance from bankcard where defaultl=1 and userId={id}'
        cursor.execute(sql)
        y = cursor.fetchall()
        money2 = y[0][0]
        self.assertEqual(money1 - 3000, money2)

        driver.quit()

